package com.winona.ui;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.taplinker.client.AppConfigFactory;
import com.taplinker.client.R;
import com.taplinker.client.core.ImageManager;
import com.winona.Base1Activity;
import com.winona.ConstantValue;
import com.winona.HomeActivity;

@SuppressLint("CutPasteId")
public class PersonalSettingActivity extends Base1Activity {

	private TextView title;
	private Intent intent;
	private ImageButton setting_back;
	private View setting_name, setting_system, setting_about;
	private TextView set_name;
	private ImageView set_head;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.per_setting);
		findView();
		title.setText("个人设置");
		ClickListener();
	}

	private void findView() {
		title = (TextView) findViewById(R.id.setting_title);
		setting_back = (ImageButton) findViewById(R.id.setting_back);
		setting_name = findViewById(R.id.setting_name);
		setting_system = findViewById(R.id.setting_system);
		setting_about = findViewById(R.id.setting_about);

		set_name = (TextView) findViewById(R.id.set_name);
		set_head = (ImageView) findViewById(R.id.setting_head);
		set_name.setText(AppConfigFactory.getInstance().getUserInfo()
				.getUserName());
		
//		if (AppConfigFactory.getInstance().getExpert() != null) {
//
//			ImageManager.getInstance().loadImage(
//					AppConfigFactory.getInstance().getExpert().getHead(),
//					set_head, 0, 0, null);
//		}
		if(!TextUtils.isEmpty(AppConfigFactory.getInstance().getExpert().getHead())){
			ImageManager.getInstance().loadImage(ConstantValue.IMAGE + AppConfigFactory.getInstance().getExpert().getHead(),
					set_head, 60, 60, null);
			}
	}

	private void ClickListener() {
		setting_back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				intent = getIntent();
				String value = intent.getExtras().getString("set");
				if (value.equals("0")) {
					openMenu();
				} else {

					startActivity(HomeActivity.class);
				}
			}
		});

		setting_name.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				startActivity(PerInfoActivity.class);
			}
		});
		setting_system.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				startActivity(SystemSetActivity.class);
			}
		});
		setting_about.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				startActivity(AboutActivity.class);
			}
		});

	}

}
